#pragma once
#include"RBTree.h"

namespace xlf
{
	template<class K>
	class Set
	{
		struct SetKeyOfT
		{
			const K& operator()(const K& key)//仿函数
			{
				return key;
			}
		};

	public:
		typedef typename RBTree<K, K, SetKeyOfT>::Iterator iterator;

		iterator begin()
		{
			return _t.Begin();
		}

		iterator end()
		{
			return _t.End();
		}

		bool insert(const K& key)
		{
			return _t.Insert(key);
		}

	private:
		RBTree<K, K, SetKeyOfT> _t;
	};

	void test_set()
	{
		Set<int> s;
		//int a[] = { 16,3,7,11,9,26,18,14,15 };
		int a[] = { 4,2,6,1,3,5,15,7,16,14 };
		for (auto e : a)
		{
			s.insert(e);
		}

		for (auto e : s)
		{
			cout << e << " ";
		}
		cout << endl;
	}
}